package com.ak.player;


import java.util.Date;


import java.util.ArrayList;

import java.util.HashMap;

import com.ak.cluster.ItemReader;

import com.ak.cluster.GameObject;

public class Player {
	
	public String userName;
	public HashMap<String,Object> playerData;
	public String welcomeMessage;
	public ArrayList<GameObject> playerItems;
	
	public Player()
	{
		playerItems = new ArrayList <GameObject>();
		playerData = new HashMap<String,Object>();
		ItemReader ir = new ItemReader(this);
		Date now = new Date();
		ir.load(this);

		if(playerData.containsKey("Username"))
			playerData.put("Username", "Player");
		else
			playerData.put("Username", "New User");
		
		
		if(playerData.containsKey("LastLogin"))
		{
			playerData.put("LastLogin", now.getTime());
			welcomeMessage = "Welcome Back "+playerData.get("Username")+"!";
		}
		else 
		{
			welcomeMessage = "Greetings "+playerData.get("Username")+"!";
			playerData.put("LastLogin", now.getTime());
		}
			
		//Save on completion... not here
		ir.save(this);
	}

}
